home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWODPart.cpp < prev    next >
Encoding:
Text File  |  1996-08-16  |  56.1 KB  |  2,184 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWODPart.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWODPART_H
  13. #include "FWODPart.h"
  14. #endif
  15.  
  16. #ifndef FWPART_H
  17. #include "FWPart.h"
  18. #endif
  19.  
  20. #ifndef FWPRMISE_H
  21. #include "FWPrmise.h"
  22. #endif
  23.  
  24. #ifndef FWDRGDRP_H
  25. #include "FWDrgDrp.h"
  26. #endif
  27.  
  28. #ifndef FWFRMING_H
  29. #include "FWFrming.h"
  30. #endif
  31.  
  32. #ifndef FWPRTITE_H
  33. #include "FWPrtIte.h"
  34. #endif
  35.  
  36. #ifndef FWPRESEN_H
  37. #include "FWPresen.h"
  38. #endif
  39.  
  40. #ifndef FWPXYFRM_H
  41. #include "FWPxyFrm.h"
  42. #endif
  43.  
  44. #ifndef FWPROXY_H
  45. #include "FWProxy.h"
  46. #endif
  47.  
  48. #ifndef FWLNKMGR_H
  49. #include "FWLnkMgr.h"
  50. #endif
  51.  
  52. #ifndef FWCMD_H
  53. #include "FWCmd.h"
  54. #endif
  55.  
  56. #ifndef FWBARRAY_H
  57. #include "FWBArray.h"
  58. #endif
  59.  
  60. #ifndef FWODGEOM_H
  61. #include "FWODGeom.h"
  62. #endif
  63.  
  64. #ifndef FWMNUBAR_H
  65. #include "FWMnuBar.h"
  66. #endif
  67.  
  68. #ifndef FWUTIL_H
  69. #include "FWUtil.h"
  70. #endif
  71.  
  72. #ifndef FWCLNINF_H
  73. #include "FWClnInf.h"
  74. #endif
  75.  
  76. #ifndef FWDEBUG_H
  77. #include "FWDebug.h"
  78. #endif
  79.  
  80. #ifndef FWEVENTD_H
  81. #include "FWEventD.h"
  82. #endif
  83.  
  84. #ifndef FWLNKITE_H
  85. #include "FWLnkIte.h"
  86. #endif
  87.  
  88. #ifndef FWINTER_H
  89. #include "FWInter.h"
  90. #endif
  91.  
  92. // ----- OpenDoc Includes -----
  93.  
  94. #ifndef SOM_Module_OpenDoc_Commands_defined
  95. #include <CmdDefs.xh>
  96. #endif
  97.  
  98. #ifndef SOM_ODFrame_xh
  99. #include <Frame.xh>
  100. #endif
  101.  
  102. #ifndef SOM_ODLinkSource_xh
  103. #include <LinkSrc.xh>
  104. #endif
  105.  
  106. #ifndef SOM_ODLink_xh
  107. #include <Link.xh>
  108. #endif
  109.  
  110. #ifndef SOM_ODClipboard_xh
  111. #include <Clipbd.xh>
  112. #endif
  113.  
  114. #ifndef SOM_ODDraft_xh
  115. #include <Draft.xh>
  116. #endif
  117.  
  118. #ifndef SOM_ODSession_xh
  119. #include <ODSessn.xh>
  120. #endif
  121.  
  122. #ifndef SOM_Module_OpenDoc_StdProps_defined
  123. #include <StdProps.xh>
  124. #endif
  125.  
  126. #ifndef SOM_ODArbitrator_xh
  127. #include <Arbitrat.xh>
  128. #endif
  129.  
  130. #ifndef SOM_Module_OpenDoc_Errors_defined
  131. #include <ErrorDef.xh>
  132. #endif
  133.  
  134. //========================================================================================
  135. // Runtime Information
  136. //========================================================================================
  137.  
  138. #ifdef FW_BUILD_MAC
  139. #pragma segment fwpart3
  140. #endif
  141.  
  142. const char* kUnknownExceptionString = "Unknown exception!";
  143.  
  144. //========================================================================================
  145. // class FW_CODPart
  146. //========================================================================================
  147.  
  148. //---------------------------------------------------------------------------------------
  149. //    FW_CODPart::FulfillPromise
  150. //---------------------------------------------------------------------------------------
  151.  
  152. void FW_CODPart::FulfillPromise(Environment *ev, FW_CPart* part, ODStorageUnitView* promiseSUView)
  153. {
  154. FW_UNUSED(part);
  155.     FW_TRY
  156.     {        
  157.         FW_CPromise* promise = NULL;
  158.     
  159.         FW_CByteArray bArray;
  160.         promiseSUView->GetValue(ev, sizeof(FW_CPromise*), bArray);
  161.         bArray.CopyBuffer(&promise, sizeof(FW_CPromise*));
  162.         
  163.         promiseSUView->SetOffset(ev, 0);
  164.         
  165.         long count = promise->PrivHandleFulfillPromise(ev, promiseSUView);
  166.         
  167.         if (count == 0)
  168.             delete promise;    // we are done with it
  169.     }
  170.     FW_CATCH_BEGIN
  171.     FW_CATCH_REFERENCE(FW_XException, exception)
  172.     {
  173.         FW_SetException(ev, exception);
  174.     }
  175.     FW_CATCH_EVERYTHING()
  176.     {
  177.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  178.         FW_SetEvError(ev, kODErrUndefined);
  179.     }
  180.     FW_CATCH_END
  181. }
  182.  
  183. //---------------------------------------------------------------------------------------
  184. //    FW_CODPart::DragEnter
  185. //---------------------------------------------------------------------------------------
  186.  
  187. ODDragResult FW_CODPart::DragEnter(Environment *ev,
  188.                                     ODDragItemIterator* dragInfo,
  189.                                     ODFacet* facet,
  190.                                     const FW_CPoint& where)
  191. {
  192.     ODDragResult result = FALSE;
  193.     
  194.     FW_TRY
  195.     {
  196.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  197.         FW_ASSERT(frame);
  198.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  199.         if (droppable)
  200.             result = droppable->DragEnter(ev, facet, dragInfo, where);
  201.     }
  202.     FW_CATCH_BEGIN
  203.     FW_CATCH_REFERENCE(FW_XException, exception)
  204.     {
  205.         FW_SetException(ev, exception);
  206.     }
  207.     FW_CATCH_EVERYTHING()
  208.     {
  209.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  210.         FW_SetEvError(ev, kODErrUndefined);
  211.     }
  212.     FW_CATCH_END
  213.     
  214.     return result;
  215. }
  216.  
  217. //---------------------------------------------------------------------------------------
  218. //    FW_CODPart::DragWithin
  219. //---------------------------------------------------------------------------------------
  220.  
  221. ODDragResult FW_CODPart::DragWithin(Environment *ev,
  222.                                         ODDragItemIterator* dragInfo,
  223.                                         ODFacet* facet,
  224.                                         const FW_CPoint& where)
  225. {
  226.     ODDragResult result = FALSE;
  227.  
  228.     FW_TRY
  229.     {
  230.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  231.         FW_ASSERT(frame);
  232.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  233.         if (droppable)
  234.             result = droppable->DragWithin(ev, facet, dragInfo, where);
  235.     }
  236.     FW_CATCH_BEGIN
  237.     FW_CATCH_REFERENCE(FW_XException, exception)
  238.     {
  239.         FW_SetException(ev, exception);
  240.     }
  241.     FW_CATCH_EVERYTHING()
  242.     {
  243.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  244.         FW_SetEvError(ev, kODErrUndefined);
  245.     }
  246.     FW_CATCH_END
  247.     
  248.     return result;
  249. }
  250.  
  251. //---------------------------------------------------------------------------------------
  252. //    FW_CODPart::DragLeave
  253. //---------------------------------------------------------------------------------------
  254.  
  255. void FW_CODPart::DragLeave(Environment *ev,
  256.                             ODFacet* facet,
  257.                             const FW_CPoint& where)
  258. {
  259.     FW_TRY
  260.     {
  261.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  262.         FW_ASSERT(frame);
  263.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  264.         if (droppable)
  265.             droppable->DragLeave(ev, facet, where);
  266.     }
  267.     FW_CATCH_BEGIN
  268.     FW_CATCH_REFERENCE(FW_XException, exception)
  269.     {
  270.         FW_SetException(ev, exception);
  271.     }
  272.     FW_CATCH_EVERYTHING()
  273.     {
  274.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  275.         FW_SetEvError(ev, kODErrUndefined);
  276.     }
  277.     FW_CATCH_END
  278. }
  279.  
  280. //---------------------------------------------------------------------------------------
  281. //    FW_CODPart::Drop
  282. //---------------------------------------------------------------------------------------
  283.  
  284. ODDropResult FW_CODPart::Drop(Environment *ev,
  285.                                 ODDragItemIterator* dropInfo,
  286.                                 ODFacet* facet,
  287.                                 const FW_CPoint& where)
  288. {
  289.     ODDropResult result = kODDropFail;
  290.     
  291.     FW_TRY
  292.     {
  293.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  294.         FW_ASSERT(frame);
  295.         FW_MDroppableFrame* droppable = frame->GetDroppable(ev);
  296.         if (droppable)
  297.             result = droppable->Drop(ev, dropInfo, facet, where);
  298.     }
  299.     FW_CATCH_BEGIN
  300.     FW_CATCH_REFERENCE(FW_XException, exception)
  301.     {
  302.         FW_SetException(ev, exception);
  303.     }
  304.     FW_CATCH_EVERYTHING()
  305.     {
  306.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  307.         FW_SetEvError(ev, kODErrUndefined);
  308.     }
  309.     FW_CATCH_END
  310.     
  311.     return result;
  312. }
  313.  
  314. //---------------------------------------------------------------------------------------
  315. //    FW_CODPart::DropCompleted
  316. //---------------------------------------------------------------------------------------
  317.  
  318. void FW_CODPart::DropCompleted(Environment *ev,
  319.                                 ODPart* destPart,
  320.                                 ODDropResult dropResult)
  321. {
  322. FW_UNUSED(destPart);
  323. FW_UNUSED(dropResult);
  324.     FW_TRY
  325.     {
  326.         FW_DEBUG_MESSAGE("DropCompleted: Not Yet Implemented");
  327.     }
  328.     FW_CATCH_BEGIN
  329.     FW_CATCH_REFERENCE(FW_XException, exception)
  330.     {
  331.         FW_SetException(ev, exception);
  332.     }
  333.     FW_CATCH_EVERYTHING()
  334.     {
  335.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  336.         FW_SetEvError(ev, kODErrUndefined);
  337.     }
  338.     FW_CATCH_END
  339. }
  340.  
  341. //---------------------------------------------------------------------------------------
  342. //    FW_CODPart::ContainingPartPropertiesUpdated
  343. //---------------------------------------------------------------------------------------
  344.  
  345. void FW_CODPart::ContainingPartPropertiesUpdated(Environment *ev,
  346.                                                     ODFrame* odFrame,
  347.                                                     ODStorageUnit* propertyUnit)
  348. {
  349.     FW_TRY
  350.     {
  351.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  352.         FW_ASSERT(frame);
  353.         frame->ContainingPartPropertiesUpdated(ev, propertyUnit);
  354.     }
  355.     FW_CATCH_BEGIN
  356.     FW_CATCH_REFERENCE(FW_XException, exception)
  357.     {
  358.         FW_SetException(ev, exception);
  359.     }
  360.     FW_CATCH_EVERYTHING()
  361.     {
  362.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  363.         FW_SetEvError(ev, kODErrUndefined);
  364.     }
  365.     FW_CATCH_END
  366. }
  367.  
  368. //---------------------------------------------------------------------------------------
  369. //    FW_CODPart::AcquireContainingPartProperties
  370. //---------------------------------------------------------------------------------------
  371.  
  372. ODStorageUnit* FW_CODPart::AcquireContainingPartProperties(Environment *ev, 
  373.                                                         FW_CEmbeddingPart* embeddingPart,
  374.                                                         ODFrame* embeddedFrame)
  375. {
  376.     ODStorageUnit* su = NULL;
  377.     
  378.     FW_TRY
  379.     {
  380.         su = embeddingPart->AcquireContainingPartProperties(ev, embeddedFrame);
  381.     }
  382.     FW_CATCH_BEGIN
  383.     FW_CATCH_REFERENCE(FW_XException, exception)
  384.     {
  385.         FW_SetException(ev, exception);
  386.     }
  387.     FW_CATCH_EVERYTHING()
  388.     {
  389.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  390.         FW_SetEvError(ev, kODErrUndefined);
  391.     }
  392.     FW_CATCH_END
  393.     
  394.     return su;
  395. }
  396.  
  397. //---------------------------------------------------------------------------------------
  398. //    FW_CODPart::RevealFrame
  399. //---------------------------------------------------------------------------------------
  400.  
  401. FW_Boolean FW_CODPart::RevealFrame(Environment *ev,
  402.                                     ODFrame* embeddedFrame,
  403.                                     ODShape* revealShape)
  404. {
  405.     ODBoolean result = FALSE;
  406.     
  407.     FW_TRY
  408.     {
  409.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  410.         FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);
  411.         FW_ASSERT(embeddingFrame);
  412.         
  413.         result = embeddingFrame->RevealFrame(ev, embeddedFrame, revealShape);
  414.     }
  415.     FW_CATCH_BEGIN
  416.     FW_CATCH_REFERENCE(FW_XException, exception)
  417.     {
  418.         FW_SetException(ev, exception);
  419.     }
  420.     FW_CATCH_EVERYTHING()
  421.     {
  422.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  423.         FW_SetEvError(ev, kODErrUndefined);
  424.     }
  425.     FW_CATCH_END
  426.     
  427.     return result;
  428. }
  429.  
  430. //---------------------------------------------------------------------------------------
  431. //    FW_CODPart::DisplayFrameAdded
  432. //---------------------------------------------------------------------------------------
  433.  
  434. void FW_CODPart::DisplayFrameAdded(Environment *ev,
  435.                                     FW_CPart* part, 
  436.                                     ODFrame* odFrame)
  437. {
  438.     FW_TRY
  439.     {
  440.         // ----- Create a global shape and transform if neccessary -----
  441.         FW_PrivSetShapeTransformMaker(ev, odFrame);
  442.     
  443.         // ----- Look for the presentation -----
  444.         FW_CPresentation* newPresentation = part->PrivGetPresentation(ev, odFrame);
  445.         odFrame->SetPresentation(ev, newPresentation->GetPresentationType(ev));
  446.     
  447.         // ----- Create the frame -----
  448.         FW_CFrame* frame = newPresentation->PrivNewFrame(ev, odFrame, FALSE);
  449.         if (frame == NULL)
  450.             frame = part->NewFrame(ev, odFrame,  newPresentation, FALSE);
  451.         
  452.         // ----- Create the part Info -----
  453.         odFrame->SetPartInfo(ev, (ODInfoType)frame);
  454.     
  455.         // ----- Notify the frame -----
  456.         frame->FrameAdded(ev, odFrame, FALSE);    // brand new frame
  457.     }
  458.     FW_CATCH_BEGIN
  459.     FW_CATCH_REFERENCE(FW_XException, exception)
  460.     {
  461.         FW_SetException(ev, exception);
  462.     }
  463.     FW_CATCH_EVERYTHING()
  464.     {
  465.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  466.         FW_SetEvError(ev, kODErrUndefined);
  467.     }
  468.     FW_CATCH_END
  469. }
  470.  
  471. //---------------------------------------------------------------------------------------
  472. //    FW_CODPart::AttachSourceFrame
  473. //---------------------------------------------------------------------------------------
  474.  
  475. void FW_CODPart::AttachSourceFrame(Environment *ev,
  476.                                     ODFrame* odFrame,
  477.                                     ODFrame* odSourceFrame)
  478. {
  479.     FW_TRY
  480.     {
  481.         if (odSourceFrame != NULL && odFrame != NULL)
  482.         {
  483.             FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  484.             FW_ASSERT(frame);
  485.             
  486.             FW_CFrame* sourceFrame = FW_CFrame::ODtoFWFrame(ev, odSourceFrame);
  487.             FW_ASSERT(sourceFrame != NULL);
  488.             
  489.             frame->PrivAttachSourceFrame(ev, sourceFrame);
  490.         }
  491.     }
  492.     FW_CATCH_BEGIN
  493.     FW_CATCH_REFERENCE(FW_XException, exception)
  494.     {
  495.         FW_SetException(ev, exception);
  496.     }
  497.     FW_CATCH_EVERYTHING()
  498.     {
  499.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  500.         FW_SetEvError(ev, kODErrUndefined);
  501.     }
  502.     FW_CATCH_END
  503. }
  504.  
  505. //---------------------------------------------------------------------------------------
  506. //    FW_CODPart::DisplayFrameRemoved
  507. //---------------------------------------------------------------------------------------
  508.  
  509. void FW_CODPart::DisplayFrameRemoved(Environment *ev,
  510.                                         ODFrame* odFrame)
  511. {
  512.     FW_TRY
  513.     {
  514.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  515.         FW_ASSERT(frame);
  516.         
  517.         // ----- Notify the presentation that a frame is going away
  518.         frame->GetPresentation(ev)->PrivFrameRemoved(ev, frame, FALSE);        // The frame is gone                
  519.     }
  520.     FW_CATCH_BEGIN
  521.     FW_CATCH_REFERENCE(FW_XException, exception)
  522.     {
  523.         FW_SetException(ev, exception);
  524.     }
  525.     FW_CATCH_EVERYTHING()
  526.     {
  527.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  528.         FW_SetEvError(ev, kODErrUndefined);
  529.     }
  530.     FW_CATCH_END
  531. }
  532.  
  533. //---------------------------------------------------------------------------------------
  534. //    FW_CODPart::DisplayFrameConnected
  535. //---------------------------------------------------------------------------------------
  536.  
  537. void FW_CODPart::DisplayFrameConnected(Environment *ev,
  538.                                         ODFrame* odFrame)
  539. {
  540.     FW_TRY
  541.     {
  542.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  543.         FW_ASSERT(frame);
  544.         
  545.         // ----- Notify the frame
  546.         frame->FrameAdded(ev, odFrame, TRUE);  // From storage
  547.     }
  548.     FW_CATCH_BEGIN
  549.     FW_CATCH_REFERENCE(FW_XException, exception)
  550.     {
  551.         FW_SetException(ev, exception);
  552.     }
  553.     FW_CATCH_EVERYTHING()
  554.     {
  555.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  556.         FW_SetEvError(ev, kODErrUndefined);
  557.     }
  558.     FW_CATCH_END
  559. }
  560.  
  561. //---------------------------------------------------------------------------------------
  562. //    FW_CODPart::DisplayFrameClosed
  563. //---------------------------------------------------------------------------------------
  564.  
  565. void FW_CODPart::DisplayFrameClosed(Environment *ev,
  566.                                     ODFrame* odFrame)
  567. {
  568.     FW_TRY
  569.     {
  570.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  571.         FW_ASSERT(frame != NULL);
  572.         
  573.         // ----- Notify the presentation that a frame is going away
  574.         frame->GetPresentation(ev)->PrivFrameRemoved(ev, frame, TRUE);    // frame stays in storage    
  575.     }
  576.     FW_CATCH_BEGIN
  577.     FW_CATCH_REFERENCE(FW_XException, exception)
  578.     {
  579.         FW_SetException(ev, exception);
  580.     }
  581.     FW_CATCH_EVERYTHING()
  582.     {
  583.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  584.         FW_SetEvError(ev, kODErrUndefined);
  585.     }
  586.     FW_CATCH_END
  587. }
  588.  
  589. //---------------------------------------------------------------------------------------
  590. //    FW_CODPart::FrameShapeChanged
  591. //---------------------------------------------------------------------------------------
  592.  
  593. void FW_CODPart::FrameShapeChanged(Environment *ev,
  594.                                     ODFrame* odFrame)
  595. {
  596.     FW_TRY
  597.     {
  598.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  599.         FW_ASSERT(frame != NULL);
  600.     
  601.         frame->FrameShapeChanged(ev);
  602.     }
  603.     FW_CATCH_BEGIN
  604.     FW_CATCH_REFERENCE(FW_XException, exception)
  605.     {
  606.         FW_SetException(ev, exception);
  607.     }
  608.     FW_CATCH_EVERYTHING()
  609.     {
  610.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  611.         FW_SetEvError(ev, kODErrUndefined);
  612.     }
  613.     FW_CATCH_END
  614. }
  615.  
  616. //---------------------------------------------------------------------------------------
  617. //    FW_CODPart::ViewTypeChanged
  618. //---------------------------------------------------------------------------------------
  619.  
  620. void FW_CODPart::ViewTypeChanged(Environment *ev,
  621.                                     ODFrame* odFrame)
  622. {
  623.     FW_TRY
  624.     {
  625.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  626.         FW_ASSERT(frame != NULL);
  627.         
  628.         ODTypeToken newViewType = odFrame->GetViewType(ev);
  629.         ODTypeToken oldViewType = frame->PrivGetPreviousViewType(ev);
  630.         
  631.         if (newViewType != oldViewType)
  632.         {
  633.             frame->PrivSetPreviousViewType(ev, newViewType);
  634.             frame->ViewTypeChanged(ev, newViewType, oldViewType);
  635.         }
  636.     }
  637.     FW_CATCH_BEGIN
  638.     FW_CATCH_REFERENCE(FW_XException, exception)
  639.     {
  640.         FW_SetException(ev, exception);
  641.     }
  642.     FW_CATCH_EVERYTHING()
  643.     {
  644.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  645.         FW_SetEvError(ev, kODErrUndefined);
  646.     }
  647.     FW_CATCH_END
  648. }
  649.  
  650. //---------------------------------------------------------------------------------------
  651. //    FW_CODPart::PresentationChanged
  652. //---------------------------------------------------------------------------------------
  653.  
  654. void FW_CODPart::PresentationChanged(Environment *ev,
  655.                                         ODFrame* odFrame)
  656. {
  657.     FW_TRY
  658.     {
  659.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  660.         FW_ASSERT(frame != NULL);
  661.     
  662.         frame->PresentationChanged(ev);
  663.     }
  664.     FW_CATCH_BEGIN
  665.     FW_CATCH_REFERENCE(FW_XException, exception)
  666.     {
  667.         FW_SetException(ev, exception);
  668.     }
  669.     FW_CATCH_EVERYTHING()
  670.     {
  671.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  672.         FW_SetEvError(ev, kODErrUndefined);
  673.     }
  674.     FW_CATCH_END
  675. }
  676.  
  677. //---------------------------------------------------------------------------------------
  678. //    FW_CODPart::SequenceChanged
  679. //---------------------------------------------------------------------------------------
  680.  
  681. void FW_CODPart::SequenceChanged(Environment *ev,
  682.                                     ODFrame* odFrame)
  683. {
  684.     FW_TRY
  685.     {
  686.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  687.         FW_ASSERT(frame != NULL);
  688.     
  689.         frame->SequenceChanged(ev);
  690.     }
  691.     FW_CATCH_BEGIN
  692.     FW_CATCH_REFERENCE(FW_XException, exception)
  693.     {
  694.         FW_SetException(ev, exception);
  695.     }
  696.     FW_CATCH_EVERYTHING()
  697.     {
  698.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  699.         FW_SetEvError(ev, kODErrUndefined);
  700.     }
  701.     FW_CATCH_END
  702. }
  703.  
  704. //---------------------------------------------------------------------------------------
  705. //    FW_CODPart::WritePartInfo
  706. //---------------------------------------------------------------------------------------
  707.  
  708. void FW_CODPart::WritePartInfo(Environment *ev,
  709.                                     ODInfoType partInfo,
  710.                                     ODStorageUnitView* storageUnitView)
  711. {
  712.     FW_TRY
  713.     {
  714.         FW_ASSERT(partInfo != NULL);
  715.         
  716.         FW_CFrame* frame = (FW_CFrame*) partInfo;
  717.         FW_ASSERT(frame);
  718.  
  719.         ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  720.     
  721.         FW_CAcquireODPropertyName propName(ev, storageUnitView);
  722.         FW_SUForceFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev));
  723.         
  724.         FW_CAcquireODStorageUnitView suView(ev, su);
  725.         frame->ExternalizeFrame(ev, suView);
  726.     }
  727.     FW_CATCH_BEGIN
  728.     FW_CATCH_REFERENCE(FW_XException, exception)
  729.     {
  730.         FW_SetException(ev, exception);
  731.     }
  732.     FW_CATCH_EVERYTHING()
  733.     {
  734.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  735.         FW_SetEvError(ev, kODErrUndefined);
  736.     }
  737.     FW_CATCH_END
  738. }
  739.  
  740. //---------------------------------------------------------------------------------------
  741. //    FW_CODPart::ReadPartInfo
  742. //---------------------------------------------------------------------------------------
  743.  
  744. ODInfoType FW_CODPart::ReadPartInfo(Environment *ev,
  745.                                     FW_CPart* part, 
  746.                                     ODFrame* odFrame,
  747.                                     ODStorageUnitView* storageUnitView)
  748. {
  749.     FW_CFrame* frame = NULL;
  750.     
  751.     FW_TRY
  752.     {
  753.         // ----- Create a global shape and transform if neccessary -----
  754.         FW_PrivSetShapeTransformMaker(ev, odFrame);
  755.     
  756.         // ----- Determine the presentation -----
  757.         FW_CPresentation* presentation = part->PrivGetPresentation(ev, odFrame);
  758.         odFrame->SetPresentation(ev, presentation->GetPresentationType(ev));
  759.     
  760.         // ----- Create the FW_CFrame object -----
  761.         frame = presentation->PrivNewFrame(ev, odFrame, TRUE);
  762.         if (frame == NULL)
  763.             frame = part->NewFrame(ev, odFrame, presentation, TRUE);
  764.         
  765.         // ----- Internalize the frame -----
  766.         ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  767.     
  768.         FW_CAcquireODPropertyName propName(ev, storageUnitView);;
  769.         
  770.         if (FW_SUExistsThenFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)) )
  771.         {
  772.             FW_CAcquireODStorageUnitView suView(ev, su);
  773.             frame->InternalizeFrame(ev, suView);
  774.         }
  775.     }
  776.     FW_CATCH_BEGIN
  777.     FW_CATCH_REFERENCE(FW_XException, exception)
  778.     {
  779.         FW_SetException(ev, exception);
  780.     }
  781.     FW_CATCH_EVERYTHING()
  782.     {
  783.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  784.         FW_SetEvError(ev, kODErrUndefined);
  785.     }
  786.     FW_CATCH_END
  787.     
  788.     return (ODInfoType)frame;
  789. }
  790.  
  791. //---------------------------------------------------------------------------------------
  792. //    FW_CODPart::ClonePartInfo
  793. //---------------------------------------------------------------------------------------
  794.  
  795. void FW_CODPart::ClonePartInfo(Environment *ev,
  796.                                 ODDraftKey key,
  797.                                 ODInfoType partInfo,
  798.                                 ODStorageUnitView* storageUnitView,
  799.                                 ODFrame* scope)
  800. {
  801. FW_UNUSED(key);
  802. FW_UNUSED(scope);
  803.     FW_TRY
  804.     {
  805.         FW_CODPart::WritePartInfo(ev, partInfo, storageUnitView);
  806.     
  807. //        FW_ASSERT(partInfo != NULL);
  808. //        FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)partInfo;
  809. //        FW_CFrame* frame = framePartInfo->GetFrame();
  810. //        frame->ClonePartInfo(ev, key, partInfo, storageUnitView, scope);
  811.     }
  812.     FW_CATCH_BEGIN
  813.     FW_CATCH_REFERENCE(FW_XException, exception)
  814.     {
  815.         FW_SetException(ev, exception);
  816.     }
  817.     FW_CATCH_EVERYTHING()
  818.     {
  819.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  820.         FW_SetEvError(ev, kODErrUndefined);
  821.     }
  822.     FW_CATCH_END
  823. }
  824.  
  825. //---------------------------------------------------------------------------------------
  826. //    FW_CODPart::Open
  827. //---------------------------------------------------------------------------------------
  828. //    if odFrame is != of NULL we are opening the window from storage. If odFrame == NULL it
  829. //    is the first time.
  830.  
  831. ODID FW_CODPart::Open(Environment *ev,
  832.                         FW_CPart* part,
  833.                         ODFrame* odFrame)
  834. {
  835.     ODID id = 0;
  836.     
  837.     FW_TRY
  838.     {
  839.         FW_CWindow* window = NULL;
  840.         
  841.         if (odFrame)
  842.         {
  843.             if (odFrame->IsRoot(ev))
  844.             {
  845.                 window = new FW_CWindow(ev, part, odFrame);
  846.             }
  847.             else
  848.             {
  849.                 FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  850.                 FW_ASSERT(frame != NULL);
  851.                 return frame->GetPresentation(ev)->OpenPartWindow(ev, frame, NULL);
  852.             }
  853.         }
  854.         else
  855.         {
  856.             window = part->NewDocumentWindow(ev);
  857.         }
  858.         FW_ASSERT(window);
  859.             
  860.         // ATTENTION: the order is very important
  861.         window->Show(ev);
  862.         window->Select(ev);
  863.     
  864.         id = window->GetID(ev);
  865.     }
  866.     FW_CATCH_BEGIN
  867.     FW_CATCH_REFERENCE(FW_XException, exception)
  868.     {
  869.         FW_SetException(ev, exception);
  870.     }
  871.     FW_CATCH_EVERYTHING()
  872.     {
  873.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  874.         FW_SetEvError(ev, kODErrUndefined);
  875.     }
  876.     FW_CATCH_END
  877.     
  878.     return id;
  879. }
  880.  
  881. //---------------------------------------------------------------------------------------
  882. //    FW_CODPart::RequestEmbeddedFrame
  883. //---------------------------------------------------------------------------------------
  884.  
  885. ODFrame* FW_CODPart::RequestEmbeddedFrame(Environment *ev,
  886.                                             FW_CEmbeddingPart* part,
  887.                                             ODFrame* containingFrame,
  888.                                             ODFrame* baseFrame,
  889.                                             ODShape* suggestedFrameShape,
  890.                                             ODPart* embeddedPart,
  891.                                             ODTypeToken viewType,
  892.                                             ODTypeToken presentation,
  893.                                             FW_Boolean isOverlaid)
  894. {
  895.     ODFrame* frame = NULL;
  896.     
  897.     FW_TRY
  898.     {
  899.         FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, containingFrame);
  900.         FW_ASSERT(embeddingFrame);
  901.     
  902.         FW_MProxy* baseProxy = part->GetProxy(ev, baseFrame);
  903.         FW_ASSERT(baseProxy);
  904.         
  905.         FW_ASSERT(baseFrame->GetFrameGroup(ev) == baseProxy->GetFrameGroup(ev));
  906.         ODID frameGroup = baseProxy->GetFrameGroup(ev);
  907.         FW_ASSERT(baseFrame->GetFrameGroup(ev) == frameGroup);
  908.         
  909.         FW_Boolean hasAGroup = (frameGroup != 0);
  910.         
  911.         if (!hasAGroup)
  912.         {
  913.             FW_ASSERT(baseProxy->GetSequenceNumber(ev) == 0);            
  914.             frameGroup = part->PrivGetNextFrameGroup(ev);        
  915.         }
  916.         
  917.         // ----- Call the frame -----
  918.         FW_MProxy* proxy = embeddingFrame->EmbeddedFrameRequested(ev, 
  919.                                                                 baseProxy,
  920.                                                                 baseFrame, 
  921.                                                                 suggestedFrameShape, 
  922.                                                                 embeddedPart, 
  923.                                                                 viewType, 
  924.                                                                 presentation, 
  925.                                                                 frameGroup, 
  926.                                                                 isOverlaid, 
  927.                                                                 baseFrame->IsSubframe(ev));
  928.         if (proxy == NULL)
  929.             return NULL;    // RequestEmbeddedFrame not supported
  930.         
  931.         ODID newSequenceNumber = 0;
  932.         // ----- Set the group and sequence -----
  933.         if (!hasAGroup)
  934.         {
  935.             baseProxy->PrivSetFrameGroup(ev, frameGroup);
  936.             baseProxy->ChangeSequenceNumber(ev, 1);
  937.             newSequenceNumber = 1;
  938.         }
  939.         else
  940.         {
  941.             // ----- Look for the highest sequence number ------
  942.             newSequenceNumber = 0;
  943.             FW_CPartProxyIterator ite(part);
  944.             for (FW_MProxy* aProxy = ite.First(); ite.IsNotComplete(); aProxy = ite.Next())
  945.             {
  946.                 if (aProxy->GetFrameGroup(ev) == frameGroup)
  947.                 {
  948.                     ODID sequenceNumber = aProxy->GetSequenceNumber(ev);
  949.                     if (sequenceNumber > newSequenceNumber)
  950.                         newSequenceNumber = sequenceNumber;
  951.                 }
  952.             }
  953.         }
  954.  
  955.         newSequenceNumber++;
  956.         proxy->PrivSetFrameGroup(ev, frameGroup);
  957.         proxy->ChangeSequenceNumber(ev, newSequenceNumber);
  958.                 
  959.         frame = proxy->AcquireEmbeddedFrame(ev, embeddingFrame);
  960.     }
  961.     FW_CATCH_BEGIN
  962.     FW_CATCH_REFERENCE(FW_XException, exception)
  963.     {
  964.         FW_SetException(ev, exception);
  965.     }
  966.     FW_CATCH_EVERYTHING()
  967.     {
  968.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  969.         FW_SetEvError(ev, kODErrUndefined);
  970.     }
  971.     FW_CATCH_END
  972.     
  973.     return frame;
  974. }
  975.  
  976. //---------------------------------------------------------------------------------------
  977. //    FW_CODPart::RemoveEmbeddedFrame
  978. //---------------------------------------------------------------------------------------
  979.  
  980. void FW_CODPart::RemoveEmbeddedFrame(Environment *ev,
  981.                                     FW_CEmbeddingPart* part,
  982.                                     ODFrame* embeddedFrame)
  983. {
  984.     FW_TRY
  985.     {
  986.         FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  987.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
  988.         FW_ASSERT(containingFrame != NULL);
  989.         
  990.         // ----- Find the proxy -----
  991.         FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  992.         FW_ASSERT(proxy != NULL);
  993.         
  994.         proxy->RemoveEmbeddedFrames(ev);        // remove all embedded frames
  995.  
  996.         // ----- Save frame group and sequence number -----
  997.         ODID sequenceNumber = proxy->GetSequenceNumber(ev);
  998.         ODID frameGroup = proxy->GetFrameGroup(ev);
  999.  
  1000.         // ----- Ask the part to delete it -----
  1001.         part->EmbeddedFrameRemoved(ev, proxy);    
  1002.  
  1003.         // ------ Deal with frame group and sequence number
  1004.         FW_MProxy* lonelyProxy = NULL;
  1005.         unsigned short count = 0;
  1006.         FW_CPartProxyIterator ite(part);
  1007.         for (FW_MProxy* aProxy = ite.First(); ite.IsNotComplete(); aProxy = ite.Next())
  1008.         {
  1009.             if (aProxy->GetFrameGroup(ev) == frameGroup)
  1010.             {
  1011.                 count++;
  1012.                 lonelyProxy =  aProxy;
  1013.                 ODID aSequenceNumber = aProxy->GetSequenceNumber(ev);
  1014.                 if (aSequenceNumber > sequenceNumber)
  1015.                     aProxy->ChangeSequenceNumber(ev, aSequenceNumber-1);
  1016.             }
  1017.         }
  1018.         
  1019.         // ----- In the case where I am the only proxy of this group change it back to 0 -----
  1020.         if (count == 1)
  1021.         {
  1022.             lonelyProxy->PrivSetFrameGroup(ev, 0);
  1023.             lonelyProxy->ChangeSequenceNumber(ev, 0);
  1024.         }
  1025.     }
  1026.     FW_CATCH_BEGIN
  1027.     FW_CATCH_REFERENCE(FW_XException, exception)
  1028.     {
  1029.         FW_SetException(ev, exception);
  1030.     }
  1031.     FW_CATCH_EVERYTHING()
  1032.     {
  1033.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1034.         FW_SetEvError(ev, kODErrUndefined);
  1035.     }
  1036.     FW_CATCH_END
  1037. }
  1038.  
  1039. //---------------------------------------------------------------------------------------
  1040. //    FW_CODPart::RequestFrameShape
  1041. //---------------------------------------------------------------------------------------
  1042.  
  1043. ODShape* FW_CODPart::RequestFrameShape(Environment *ev,
  1044.                                         ODFrame* embeddedFrame,
  1045.                                         ODShape* frameShape)
  1046. {
  1047.     ODShape* newFrameShape = NULL;
  1048.     
  1049.     FW_TRY
  1050.     {
  1051.         FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1052.         
  1053.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
  1054.         FW_ASSERT(containingFrame);
  1055.         
  1056.         FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  1057.         FW_ASSERT(proxy);
  1058.         
  1059.         newFrameShape = proxy->FrameShapeRequested(ev, containingFrame, embeddedFrame, frameShape);
  1060.     }
  1061.     FW_CATCH_BEGIN
  1062.     FW_CATCH_REFERENCE(FW_XException, exception)
  1063.     {
  1064.         FW_SetException(ev, exception);
  1065.     }
  1066.     FW_CATCH_EVERYTHING()
  1067.     {
  1068.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1069.         FW_SetEvError(ev, kODErrUndefined);
  1070.     }
  1071.     FW_CATCH_END
  1072.     
  1073.     return newFrameShape;
  1074. }
  1075.  
  1076. //---------------------------------------------------------------------------------------
  1077. //    FW_CODPart::UsedShapeChanged
  1078. //---------------------------------------------------------------------------------------
  1079.  
  1080. void FW_CODPart::UsedShapeChanged(Environment *ev,
  1081.                                     ODFrame* embeddedFrame)
  1082. {
  1083.     FW_TRY
  1084.     {
  1085.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1086.         FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);    
  1087.         FW_ASSERT(containingFrame != NULL);    // Should not be called if not an embedding frame or not one of our frame
  1088.     
  1089.         FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  1090.         
  1091.         //     If proxy is null it means that the embedded part is changing its used shape before
  1092.         //    I had time to finish building all my structures 
  1093.         if (proxy != NULL)
  1094.             proxy->UsedShapeChanged(ev, containingFrame, embeddedFrame);
  1095.     }
  1096.     FW_CATCH_BEGIN
  1097.     FW_CATCH_REFERENCE(FW_XException, exception)
  1098.     {
  1099.         FW_SetException(ev, exception);
  1100.     }
  1101.     FW_CATCH_EVERYTHING()
  1102.     {
  1103.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1104.         FW_SetEvError(ev, kODErrUndefined);
  1105.     }
  1106.     FW_CATCH_END
  1107. }
  1108.  
  1109. //---------------------------------------------------------------------------------------
  1110. //    FW_CODPart::AdjustBorderShape
  1111. //---------------------------------------------------------------------------------------
  1112.  
  1113. ODShape* FW_CODPart::AdjustBorderShape(Environment *ev,
  1114.                                         ODFacet* embeddedFacet,
  1115.                                         ODShape* shape)
  1116. {
  1117.     FW_TRY
  1118.     {    
  1119.         if (shape != NULL)
  1120.         {            
  1121.             ODFrame* embeddedFrame = embeddedFacet->GetFrame(ev);
  1122.             FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1123.             FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);    
  1124.             FW_ASSERT(containingFrame != NULL);    // Should not be called if not an embedding frame or not one of our frame
  1125.         
  1126.             FW_MProxy* proxy = containingFrame->GetProxy(ev, embeddedFrame);
  1127.             FW_ASSERT(proxy);            
  1128.             FW_CProxyFrame* proxyFrame = proxy->PrivGetProxyFrame(ev, embeddedFrame->GetID(ev));
  1129.             
  1130.             // ----- I need to acquire it before returning it -----        
  1131.             shape->Acquire(ev);
  1132.  
  1133.             // ----- Get transform to go from content to embedding content coordinates -----
  1134.             FW_CAcquiredODTransform tempx = FW_CopyAndRelease(ev, containingFrame->AcquireInternalTransform(ev, NULL));
  1135.             FW_CAcquiredODTransform aqExternalxForm = embeddedFacet->AcquireExternalTransform(ev, NULL);
  1136.             tempx->PostCompose(ev, aqExternalxForm);
  1137.             
  1138.             shape->Transform(ev, tempx);
  1139.  
  1140.             // ----- Intersect with content shape -----
  1141.             FW_CAcquiredODShape aqContentShape = containingFrame->AcquireContentShape(ev);
  1142.             shape->Intersect(ev, aqContentShape);
  1143.  
  1144.             // ----- Call the proxy to intersect with content -----
  1145.             proxy->AdjustBorderShape(ev, containingFrame, embeddedFacet, shape);
  1146.  
  1147.             // ----- Put it back in embeddedFacet frame coordinate -----
  1148.             shape->InverseTransform(ev, tempx);
  1149.         }
  1150.     }
  1151.     FW_CATCH_BEGIN
  1152.     FW_CATCH_REFERENCE(FW_XException, exception)
  1153.     {
  1154.         FW_SetException(ev, exception);
  1155.     }
  1156.     FW_CATCH_EVERYTHING()
  1157.     {
  1158.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1159.         FW_SetEvError(ev, kODErrUndefined);
  1160.     }
  1161.     FW_CATCH_END
  1162.     
  1163.     return shape;
  1164. }
  1165.  
  1166. //---------------------------------------------------------------------------------------
  1167. //    FW_CODPart::FacetAdded
  1168. //---------------------------------------------------------------------------------------
  1169.  
  1170. void FW_CODPart::FacetAdded(Environment *ev, ODFacet* facet)
  1171. {
  1172.     FW_TRY
  1173.     {
  1174.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1175.         FW_ASSERT(frame != NULL);
  1176.         
  1177.         // ----- Set the facet's part info -----
  1178.         FW_PrivCreateFacetPartInfo(ev, facet);
  1179.  
  1180.         // ----- Notify the frame -----
  1181.         frame->PrivFacetAdded(ev, facet);
  1182.     }
  1183.     FW_CATCH_BEGIN
  1184.     FW_CATCH_REFERENCE(FW_XException, exception)
  1185.     {
  1186.         FW_SetException(ev, exception);
  1187.     }
  1188.     FW_CATCH_EVERYTHING()
  1189.     {
  1190.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1191.         FW_SetEvError(ev, kODErrUndefined);
  1192.     }
  1193.     FW_CATCH_END
  1194. }
  1195.  
  1196. //---------------------------------------------------------------------------------------
  1197. //    FW_CODPart::FacetRemoved
  1198. //---------------------------------------------------------------------------------------
  1199.  
  1200. void FW_CODPart::FacetRemoved(Environment *ev, ODFacet* facet)
  1201. {
  1202.     FW_TRY
  1203.     {
  1204.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1205.         FW_ASSERT(frame != NULL);
  1206.         
  1207.         // ----- Notify the frame -----
  1208.         frame->PrivFacetRemoved(ev, facet);
  1209.  
  1210.         // ----- Delete the facet part info -----
  1211.         FW_PrivDeleteFacetPartInfo(ev, facet);
  1212.     }
  1213.     FW_CATCH_BEGIN
  1214.     FW_CATCH_REFERENCE(FW_XException, exception)
  1215.     {
  1216.         FW_SetException(ev, exception);
  1217.     }
  1218.     FW_CATCH_EVERYTHING()
  1219.     {
  1220.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1221.         FW_SetEvError(ev, kODErrUndefined);
  1222.     }
  1223.     FW_CATCH_END
  1224. }
  1225.  
  1226. //---------------------------------------------------------------------------------------
  1227. //    FW_CODPart::CanvasChanged
  1228. //---------------------------------------------------------------------------------------
  1229.  
  1230. void FW_CODPart::CanvasChanged(Environment *ev, ODFacet* facet)
  1231. {
  1232.     FW_TRY
  1233.     {
  1234.         FW_HGDevice graphicDevice = FW_GetFacetGraphicDevice(ev, facet);
  1235.         if(graphicDevice != NULL)
  1236.             FW_PrivGDev_CanvasChanged(graphicDevice, ev, facet->GetCanvas(ev));
  1237.     }
  1238.     FW_CATCH_BEGIN
  1239.     FW_CATCH_REFERENCE(FW_XException, exception)
  1240.     {
  1241.         FW_SetException(ev, exception);
  1242.     }
  1243.     FW_CATCH_EVERYTHING()
  1244.     {
  1245.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1246.         FW_SetEvError(ev, kODErrUndefined);
  1247.     }
  1248.     FW_CATCH_END
  1249. }
  1250.  
  1251. //---------------------------------------------------------------------------------------
  1252. //    FW_CODPart::GeometryChanged
  1253. //---------------------------------------------------------------------------------------
  1254.  
  1255. void FW_CODPart::GeometryChanged(Environment *ev,
  1256.                                     ODFacet* facet,
  1257.                                     FW_Boolean clipShapeChanged,
  1258.                                     FW_Boolean externalTransformChanged)
  1259. {
  1260.     FW_TRY
  1261.     {
  1262.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1263.         FW_ASSERT(frame != NULL);
  1264.         frame->GeometryChanged(ev, facet, clipShapeChanged, externalTransformChanged);
  1265.     }
  1266.     FW_CATCH_BEGIN
  1267.     FW_CATCH_REFERENCE(FW_XException, exception)
  1268.     {
  1269.         FW_SetException(ev, exception);
  1270.     }
  1271.     FW_CATCH_EVERYTHING()
  1272.     {
  1273.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1274.         FW_SetEvError(ev, kODErrUndefined);
  1275.     }
  1276.     FW_CATCH_END
  1277. }
  1278.  
  1279. //---------------------------------------------------------------------------------------
  1280. //    FW_CODPart::Draw
  1281. //---------------------------------------------------------------------------------------
  1282.  
  1283. void FW_CODPart::Draw(Environment *ev,
  1284.                         ODFacet* facet,
  1285.                         ODShape* invalidShape)
  1286. {
  1287.     FW_TRY
  1288.     {
  1289.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1290.         FW_ASSERT(frame != NULL);
  1291.         
  1292.         frame->HandleDraw(ev, facet, invalidShape);
  1293.     }
  1294.     FW_CATCH_BEGIN
  1295.     FW_CATCH_REFERENCE(FW_XException, exception)
  1296.     {
  1297.         FW_SetException(ev, exception);
  1298.     }
  1299.     FW_CATCH_EVERYTHING()
  1300.     {
  1301.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1302.         FW_SetEvError(ev, kODErrUndefined);
  1303.     }
  1304.     FW_CATCH_END
  1305. }
  1306.  
  1307. //---------------------------------------------------------------------------------------
  1308. //    FW_CODPart::CanvasUpdated
  1309. //---------------------------------------------------------------------------------------
  1310.  
  1311. void FW_CODPart::CanvasUpdated(Environment *ev, ODCanvas* canvas)
  1312. {
  1313. FW_UNUSED(canvas);
  1314.     FW_TRY
  1315.     {
  1316.         FW_DEBUG_MESSAGE("CanvasUpdate: Not Yet Implemented");
  1317.     }
  1318.     FW_CATCH_BEGIN
  1319.     FW_CATCH_REFERENCE(FW_XException, exception)
  1320.     {
  1321.         FW_SetException(ev, exception);
  1322.     }
  1323.     FW_CATCH_EVERYTHING()
  1324.     {
  1325.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1326.         FW_SetEvError(ev, kODErrUndefined);
  1327.     }
  1328.     FW_CATCH_END
  1329. }
  1330.  
  1331. //---------------------------------------------------------------------------------------
  1332. //    FW_CODPart::HighlightChanged
  1333. //---------------------------------------------------------------------------------------
  1334.  
  1335. void FW_CODPart::HighlightChanged(Environment *ev, ODFacet* facet)
  1336. {
  1337.     FW_TRY
  1338.     {
  1339.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1340.         frame->HighlightChanged(ev, facet);
  1341.     }
  1342.     FW_CATCH_BEGIN
  1343.     FW_CATCH_REFERENCE(FW_XException, exception)
  1344.     {
  1345.         FW_SetException(ev, exception);
  1346.     }
  1347.     FW_CATCH_EVERYTHING()
  1348.     {
  1349.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1350.         FW_SetEvError(ev, kODErrUndefined);
  1351.     }
  1352.     FW_CATCH_END
  1353. }
  1354.  
  1355. //---------------------------------------------------------------------------------------
  1356. //    FW_CODPart::GetPrintResolution
  1357. //---------------------------------------------------------------------------------------
  1358.  
  1359. unsigned long FW_CODPart::GetPrintResolution(Environment *ev, ODFrame* odFrame)
  1360. {
  1361. FW_UNUSED(odFrame);
  1362.     ODULong resolution = 0;
  1363.     
  1364.     FW_TRY
  1365.     {
  1366.         FW_DEBUG_MESSAGE("GetPrintResolution: Not Yet Implemented");
  1367.     }
  1368.     FW_CATCH_BEGIN
  1369.     FW_CATCH_REFERENCE(FW_XException, exception)
  1370.     {
  1371.         FW_SetException(ev, exception);
  1372.     }
  1373.     FW_CATCH_EVERYTHING()
  1374.     {
  1375.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1376.         FW_SetEvError(ev, kODErrUndefined);
  1377.     }
  1378.     FW_CATCH_END
  1379.     
  1380.     return resolution;
  1381. }
  1382.  
  1383. //---------------------------------------------------------------------------------------
  1384. //    FW_CODPart::CreateLink
  1385. //---------------------------------------------------------------------------------------
  1386.  
  1387. ODLinkSource* FW_CODPart::CreateLink(Environment *ev, FW_CPart* part, ODByteArray* data)
  1388. {
  1389.     ODLinkSource* odLinkSource = NULL;
  1390.  
  1391.     FW_TRY
  1392.     {
  1393.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1394.         FW_ASSERT(linkMgr);
  1395.         odLinkSource = linkMgr->CreateLink(ev, data);
  1396.     }
  1397.     FW_CATCH_BEGIN
  1398.     FW_CATCH_REFERENCE(FW_XException, exception)
  1399.     {
  1400.         FW_SetException(ev, exception);
  1401.     }
  1402.     FW_CATCH_EVERYTHING()
  1403.     {
  1404.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1405.         FW_SetEvError(ev, kODErrUndefined);
  1406.     }
  1407.     FW_CATCH_END
  1408.     
  1409.     return odLinkSource;
  1410. }
  1411.  
  1412. //---------------------------------------------------------------------------------------
  1413. //    FW_CODPart::LinkUpdated
  1414. //---------------------------------------------------------------------------------------
  1415.  
  1416. void FW_CODPart::LinkUpdated(Environment *ev,
  1417.                                 FW_CPart* part,
  1418.                                 ODLink* updatedLink,
  1419.                                 ODUpdateID updateID)
  1420. {
  1421.     FW_TRY
  1422.     {
  1423.         // Notify all the links that are destinations of the updated link
  1424.         FW_CPartLinkDestIterator iter(part);
  1425.         for (FW_CLinkDestination* link = iter.First(); iter.IsNotComplete(); link = iter.Next())
  1426.         {
  1427.             if (updatedLink->IsEqualTo(ev, link->GetODLink(ev)) && (link->IsAutoUpdate(ev)))
  1428.             {
  1429.                 link->LinkUpdated(ev, updateID);
  1430.             }
  1431.         }
  1432.     }
  1433.     FW_CATCH_BEGIN
  1434.     FW_CATCH_REFERENCE(FW_XException, exception)
  1435.     {
  1436.         FW_SetException(ev, exception);
  1437.     }
  1438.     FW_CATCH_EVERYTHING()
  1439.     {
  1440.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1441.         FW_SetEvError(ev, kODErrUndefined);
  1442.     }
  1443.     FW_CATCH_END
  1444. }
  1445.  
  1446. //---------------------------------------------------------------------------------------
  1447. //    FW_CODPart::RevealLink
  1448. //---------------------------------------------------------------------------------------
  1449.  
  1450. void FW_CODPart::RevealLink(Environment *ev, FW_CPart* part, ODLinkSource* linkSource)
  1451. {
  1452.     FW_TRY
  1453.     {
  1454.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1455.         FW_ASSERT(linkMgr);
  1456.         linkMgr->RevealLink(ev, linkSource);
  1457.     }
  1458.     FW_CATCH_BEGIN
  1459.     FW_CATCH_REFERENCE(FW_XException, exception)
  1460.     {
  1461.         FW_SetException(ev, exception);
  1462.     }
  1463.     FW_CATCH_EVERYTHING()
  1464.     {
  1465.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1466.         FW_SetEvError(ev, kODErrUndefined);
  1467.     }
  1468.     FW_CATCH_END
  1469. }
  1470.  
  1471. //---------------------------------------------------------------------------------------
  1472. //    FW_CODPart::EmbeddedFrameUpdated
  1473. //---------------------------------------------------------------------------------------
  1474.  
  1475. void FW_CODPart::EmbeddedFrameUpdated(Environment *ev,
  1476.                                       FW_CPart* part,
  1477.                                       ODFrame* odFrame,
  1478.                                       ODUpdateID updateID)
  1479. {
  1480.     FW_TRY
  1481.     {
  1482.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1483.         if (linkMgr)
  1484.             linkMgr->DoUpdateLinks(ev, odFrame, updateID);
  1485.     }
  1486.     FW_CATCH_BEGIN
  1487.     FW_CATCH_REFERENCE(FW_XException, exception)
  1488.     {
  1489.         FW_SetException(ev, exception);
  1490.     }
  1491.     FW_CATCH_EVERYTHING()
  1492.     {
  1493.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1494.         FW_SetEvError(ev, kODErrUndefined);
  1495.     }
  1496.     FW_CATCH_END
  1497. }
  1498.  
  1499. //---------------------------------------------------------------------------------------
  1500. //    FW_CODPart::EditInLinkAttempted
  1501. //---------------------------------------------------------------------------------------
  1502.  
  1503. FW_Boolean FW_CODPart::EditInLinkAttempted(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1504. {
  1505.     FW_Boolean result = FALSE;
  1506.     
  1507.     FW_TRY
  1508.     {
  1509.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1510.         FW_ASSERT(linkMgr);
  1511.         result = linkMgr->EditInLinkAttempted(ev, odFrame);
  1512.     }
  1513.     FW_CATCH_BEGIN
  1514.     FW_CATCH_REFERENCE(FW_XException, exception)
  1515.     {
  1516.         FW_SetException(ev, exception);
  1517.     }
  1518.     FW_CATCH_EVERYTHING()
  1519.     {
  1520.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1521.         FW_SetEvError(ev, kODErrUndefined);
  1522.     }
  1523.     FW_CATCH_END
  1524.     
  1525.     return result;
  1526. }
  1527.  
  1528. //---------------------------------------------------------------------------------------
  1529. //    FW_CODPart::LinkStatusChanged
  1530. //---------------------------------------------------------------------------------------
  1531.  
  1532. void FW_CODPart::LinkStatusChanged(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1533. {
  1534.     FW_TRY
  1535.     {
  1536.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1537.         if (linkMgr)
  1538.             linkMgr->DoChangeLinkStatus(ev, odFrame);
  1539.         else
  1540.             part->LinkStatusChanged(ev, odFrame);
  1541.     }
  1542.     FW_CATCH_BEGIN
  1543.     FW_CATCH_REFERENCE(FW_XException, exception)
  1544.     {
  1545.         FW_SetException(ev, exception);
  1546.     }
  1547.     FW_CATCH_EVERYTHING()
  1548.     {
  1549.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1550.         FW_SetEvError(ev, kODErrUndefined);
  1551.     }
  1552.     FW_CATCH_END
  1553. }
  1554.  
  1555. //---------------------------------------------------------------------------------------
  1556. //    FW_CODPart::BeginRelinquishFocus
  1557. //---------------------------------------------------------------------------------------
  1558.  
  1559. FW_Boolean FW_CODPart::BeginRelinquishFocus(Environment *ev,
  1560.                                             FW_CPart* part,
  1561.                                             ODTypeToken focus,
  1562.                                             ODFrame* odOwnerFrame,
  1563.                                             ODFrame* proposedFrame)
  1564. {
  1565.     FW_Boolean result = FALSE;
  1566.     
  1567.     FW_TRY
  1568.     {
  1569.         if (focus == FW_CPart::gModalFocusToken)
  1570.         {
  1571.             FW_CAcquiredODPart aqODPart = proposedFrame->AcquirePart(ev);
  1572.              return (aqODPart == part->GetODPart(ev));
  1573.         }
  1574.     
  1575.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
  1576.         result = frame->BeginRelinquishFocus(ev, focus, proposedFrame);
  1577.     }
  1578.     FW_CATCH_BEGIN
  1579.     FW_CATCH_REFERENCE(FW_XException, exception)
  1580.     {
  1581.         FW_SetException(ev, exception);
  1582.     }
  1583.     FW_CATCH_EVERYTHING()
  1584.     {
  1585.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1586.         FW_SetEvError(ev, kODErrUndefined);
  1587.     }
  1588.     FW_CATCH_END
  1589.     
  1590.     return result;
  1591. }
  1592.  
  1593. //---------------------------------------------------------------------------------------
  1594. //    FW_CODPart::CommitRelinquishFocus
  1595. //---------------------------------------------------------------------------------------
  1596.  
  1597. void FW_CODPart::CommitRelinquishFocus(Environment *ev,
  1598.                                         ODTypeToken focus,
  1599.                                         ODFrame* odOwnerFrame,
  1600.                                         ODFrame* odProposedFrame)
  1601. {
  1602.     FW_TRY
  1603.     {
  1604.         FW_CFrame* ownerFrame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
  1605.         FW_ASSERT(ownerFrame != NULL);
  1606.     
  1607.         ownerFrame->FocusStateChanged(ev, focus, FALSE, odProposedFrame);
  1608.     }
  1609.     FW_CATCH_BEGIN
  1610.     FW_CATCH_REFERENCE(FW_XException, exception)
  1611.     {
  1612.         FW_SetException(ev, exception);
  1613.     }
  1614.     FW_CATCH_EVERYTHING()
  1615.     {
  1616.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1617.         FW_SetEvError(ev, kODErrUndefined);
  1618.     }
  1619.     FW_CATCH_END
  1620. }
  1621.  
  1622. //---------------------------------------------------------------------------------------
  1623. //    FW_CODPart::AbortRelinquishFocus
  1624. //---------------------------------------------------------------------------------------
  1625.  
  1626. void FW_CODPart::AbortRelinquishFocus(Environment *ev,
  1627.                                         ODTypeToken focus,
  1628.                                         ODFrame* ownerFrame,
  1629.                                         ODFrame* proposedFrame)
  1630. {
  1631.     FW_TRY
  1632.     {
  1633.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1634.         FW_ASSERT(frame);
  1635.         
  1636.         frame->AbortRelinquishFocus(ev, focus, proposedFrame);
  1637.     }
  1638.     FW_CATCH_BEGIN
  1639.     FW_CATCH_REFERENCE(FW_XException, exception)
  1640.     {
  1641.         FW_SetException(ev, exception);
  1642.     }
  1643.     FW_CATCH_EVERYTHING()
  1644.     {
  1645.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1646.         FW_SetEvError(ev, kODErrUndefined);
  1647.     }
  1648.     FW_CATCH_END
  1649. }
  1650.  
  1651. //---------------------------------------------------------------------------------------
  1652. //    FW_CODPart::FocusAcquired
  1653. //---------------------------------------------------------------------------------------
  1654.  
  1655. void FW_CODPart::FocusAcquired(Environment *ev,
  1656.                                 ODTypeToken focus,
  1657.                                 ODFrame* ownerFrame)
  1658. {
  1659.     FW_TRY
  1660.     {
  1661.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1662.         FW_ASSERT(frame != NULL);
  1663.         
  1664.         frame->FocusStateChanged(ev, focus, TRUE, NULL);
  1665.     }
  1666.     FW_CATCH_BEGIN
  1667.     FW_CATCH_REFERENCE(FW_XException, exception)
  1668.     {
  1669.         FW_SetException(ev, exception);
  1670.     }
  1671.     FW_CATCH_EVERYTHING()
  1672.     {
  1673.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1674.         FW_SetEvError(ev, kODErrUndefined);
  1675.     }
  1676.     FW_CATCH_END
  1677. }
  1678.  
  1679. //---------------------------------------------------------------------------------------
  1680. //    FW_CODPart::FocusLost
  1681. //---------------------------------------------------------------------------------------
  1682.  
  1683. void FW_CODPart::FocusLost(Environment *ev,
  1684.                             ODTypeToken focus,
  1685.                             ODFrame* ownerFrame)
  1686. {
  1687.     FW_TRY
  1688.     {
  1689.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1690.         FW_ASSERT(frame != NULL);
  1691.         
  1692.         frame->FocusStateChanged(ev, focus, FALSE, NULL);
  1693.     }
  1694.     FW_CATCH_BEGIN
  1695.     FW_CATCH_REFERENCE(FW_XException, exception)
  1696.     {
  1697.         FW_SetException(ev, exception);
  1698.     }
  1699.     FW_CATCH_EVERYTHING()
  1700.     {
  1701.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1702.         FW_SetEvError(ev, kODErrUndefined);
  1703.     }
  1704.     FW_CATCH_END
  1705. }
  1706.  
  1707. //---------------------------------------------------------------------------------------
  1708. //    FW_CODPart::CloneInto
  1709. //---------------------------------------------------------------------------------------
  1710.  
  1711. void FW_CODPart::CloneInto(Environment *ev,
  1712.                             FW_CPart* part,
  1713.                             ODDraftKey key,
  1714.                             ODStorageUnit* toSU,
  1715.                             ODFrame* scope)
  1716. {
  1717.     FW_TRY
  1718.     {
  1719.         // Since this method may be called multiple times during one Cloning
  1720.         // transaction, the Part should check to see whether it really needs
  1721.         // to write out any data
  1722.         if (toSU->Exists(ev, kODPropContents, part->GetPartKind(ev), 0))
  1723.             return;
  1724.     
  1725.         part->AddProperties(ev, toSU);
  1726.         
  1727.         part->PrivCloneInto(ev, key, toSU, scope);
  1728.     }
  1729.     FW_CATCH_BEGIN
  1730.     FW_CATCH_REFERENCE(FW_XException, exception)
  1731.     {
  1732.         FW_SetException(ev, exception);
  1733.     }
  1734.     FW_CATCH_EVERYTHING()
  1735.     {
  1736.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1737.         FW_SetEvError(ev, kODErrUndefined);
  1738.     }
  1739.     FW_CATCH_END
  1740. }
  1741.  
  1742. //---------------------------------------------------------------------------------------
  1743. //    FW_CODPart::ExternalizeKinds
  1744. //---------------------------------------------------------------------------------------
  1745.  
  1746. void FW_CODPart::ExternalizeKinds(Environment *ev, ODTypeList* kindset)
  1747. {
  1748. FW_UNUSED(kindset);
  1749.     FW_TRY
  1750.     {
  1751.         FW_DEBUG_MESSAGE("ExternalizeKinds: Not Yet Implemented");
  1752.     }
  1753.     FW_CATCH_BEGIN
  1754.     FW_CATCH_REFERENCE(FW_XException, exception)
  1755.     {
  1756.         FW_SetException(ev, exception);
  1757.     }
  1758.     FW_CATCH_EVERYTHING()
  1759.     {
  1760.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1761.         FW_SetEvError(ev, kODErrUndefined);
  1762.     }
  1763.     FW_CATCH_END
  1764. }
  1765.  
  1766. //---------------------------------------------------------------------------------------
  1767. //    FW_CODPart::ChangeKind
  1768. //---------------------------------------------------------------------------------------
  1769.  
  1770. void FW_CODPart::ChangeKind(Environment *ev, ODType kind)
  1771. {
  1772. FW_UNUSED(kind);
  1773.     FW_TRY
  1774.     {
  1775.         FW_DEBUG_MESSAGE("ChangeKind: Not Yet Implemented");
  1776.     }
  1777.     FW_CATCH_BEGIN
  1778.     FW_CATCH_REFERENCE(FW_XException, exception)
  1779.     {
  1780.         FW_SetException(ev, exception);
  1781.     }
  1782.     FW_CATCH_EVERYTHING()
  1783.     {
  1784.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1785.         FW_SetEvError(ev, kODErrUndefined);
  1786.     }
  1787.     FW_CATCH_END
  1788. }
  1789.  
  1790. //---------------------------------------------------------------------------------------
  1791. //    FW_CODPart::HandleEvent
  1792. //---------------------------------------------------------------------------------------
  1793.  
  1794. FW_Boolean FW_CODPart::HandleEvent(Environment *ev,
  1795.                                     FW_CPart* part,
  1796.                                     ODEventData* event,
  1797.                                     ODFrame* odFrame,
  1798.                                     ODFacet* odFacet,
  1799.                                     ODEventInfo* eventInfo)
  1800. {
  1801.     //     Set the default value to TRUE so if Dispatch fails while trying to handle the
  1802.     //    event I will still returns true. Dispatch will anyway returns FALSE if I don't
  1803.     //    handle the event. It is unlikely that I will fail in not handling the event.
  1804.     ODBoolean handled = TRUE;
  1805.     
  1806.     FW_TRY
  1807.     {
  1808.         handled = part->GetEventDispatcher(ev)->Dispatch(ev, event, odFrame, odFacet, eventInfo);
  1809.     }
  1810.     FW_CATCH_BEGIN
  1811.     FW_CATCH_REFERENCE(FW_XException, exception)
  1812.     {
  1813.         FW_SetException(ev, exception);
  1814.     }
  1815.     FW_CATCH_EVERYTHING()
  1816.     {
  1817.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1818.         FW_SetEvError(ev, kODErrUndefined);
  1819.     }
  1820.     FW_CATCH_END
  1821.     
  1822.     return handled;
  1823. }
  1824.  
  1825. //---------------------------------------------------------------------------------------
  1826. //    FW_CODPart::AdjustMenus
  1827. //---------------------------------------------------------------------------------------
  1828.  
  1829. void FW_CODPart::AdjustMenus(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1830. {
  1831.     FW_TRY
  1832.     {
  1833.         FW_CFrame *frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  1834.         FW_ASSERT(frame != NULL);
  1835.         
  1836.         // ----- Look if this frame has the menuFocus -----
  1837.         ODArbitrator* arbitrator = part->GetSession(ev)->GetArbitrator(ev);
  1838.         FW_CAcquiredODFrame aqFrameWithFocus = arbitrator->AcquireFocusOwner(ev, FW_CPart::gMenuFocusToken);
  1839.         
  1840.         FW_CMenuBar *menuBar = part->GetMenuBar(ev);
  1841.         menuBar->DisableAll(ev);
  1842.     
  1843.         FW_Boolean hasMenuFocus = (aqFrameWithFocus == odFrame);
  1844.         FW_Boolean rootFrame = frame->IsRoot(ev);
  1845.  
  1846.         FW_MEventHandler* target = frame->GetTarget(ev);
  1847.         FW_Boolean handled = FALSE;
  1848.         while (target != NULL && handled == FALSE)
  1849.         {
  1850.             handled = target->DispatchAdjustMenus(ev, menuBar, hasMenuFocus, rootFrame);
  1851.                 
  1852.             target = target->GetNextEventHandler(ev);
  1853.         }
  1854.     }
  1855.     FW_CATCH_BEGIN
  1856.     FW_CATCH_REFERENCE(FW_XException, exception)
  1857.     {
  1858.         FW_SetException(ev, exception);
  1859.     }
  1860.     FW_CATCH_EVERYTHING()
  1861.     {
  1862.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1863.         FW_SetEvError(ev, kODErrUndefined);
  1864.     }
  1865.     FW_CATCH_END
  1866. }
  1867.  
  1868. //---------------------------------------------------------------------------------------
  1869. //    FW_CODPart::UndoAction
  1870. //---------------------------------------------------------------------------------------
  1871.  
  1872. void FW_CODPart::UndoAction(Environment *ev, FW_CPart* part, ODActionData* actionState)
  1873. {
  1874. FW_UNUSED(part);
  1875.     FW_TRY
  1876.     {
  1877.         // actionState may contain a pointer to the command object
  1878.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1879.         {
  1880.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1881.             FW_ASSERT(command);
  1882.             if (command)    // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
  1883.                 command->UndoIt(ev);
  1884.         }
  1885.     }
  1886.     FW_CATCH_BEGIN
  1887.     FW_CATCH_REFERENCE(FW_XException, exception)
  1888.     {
  1889.         FW_SetException(ev, exception);
  1890.     }
  1891.     FW_CATCH_EVERYTHING()
  1892.     {
  1893.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1894.         FW_SetEvError(ev, kODErrUndefined);
  1895.     }
  1896.     FW_CATCH_END
  1897. }
  1898.  
  1899. //---------------------------------------------------------------------------------------
  1900. //    FW_CODPart::RedoAction
  1901. //---------------------------------------------------------------------------------------
  1902.  
  1903. void FW_CODPart::RedoAction(Environment *ev, ODActionData* actionState)
  1904. {
  1905.     FW_TRY
  1906.     {
  1907.         // actionState may contain a pointer to the command object
  1908.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1909.         {
  1910.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1911.             FW_ASSERT(command);
  1912.             if (command)    // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
  1913.                 command->RedoIt(ev);
  1914.         }
  1915.     }
  1916.     FW_CATCH_BEGIN
  1917.     FW_CATCH_REFERENCE(FW_XException, exception)
  1918.     {
  1919.         FW_SetException(ev, exception);
  1920.     }
  1921.     FW_CATCH_EVERYTHING()
  1922.     {
  1923.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1924.         FW_SetEvError(ev, kODErrUndefined);
  1925.     }
  1926.     FW_CATCH_END
  1927. }
  1928.  
  1929. //---------------------------------------------------------------------------------------
  1930. //    FW_CODPart::DisposeActionState
  1931. //---------------------------------------------------------------------------------------
  1932.  
  1933. void FW_CODPart::DisposeActionState(Environment *ev,
  1934.                                     ODActionData* actionState,
  1935.                                     ODDoneState doneState)
  1936. {
  1937.     FW_TRY
  1938.     {
  1939.         // actionState may contain a pointer to the command object
  1940.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1941.         {
  1942.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1943.             FW_ASSERT(command);
  1944.             if (command == NULL)    // [EXERPART] Should not happen but the exerPart calls me with nothing to undo
  1945.                 return;
  1946.                 
  1947.             if (doneState == kODUndone)
  1948.                 command->CommitUndone(ev);
  1949.             else    // doneState is kODDone or kODRedone
  1950.                 command->CommitDone(ev);
  1951.             delete command;
  1952.         }
  1953.     }
  1954.     FW_CATCH_BEGIN
  1955.     FW_CATCH_REFERENCE(FW_XException, exception)
  1956.     {
  1957.         FW_SetException(ev, exception);
  1958.     }
  1959.     FW_CATCH_EVERYTHING()
  1960.     {
  1961.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1962.         FW_SetEvError(ev, kODErrUndefined);
  1963.     }
  1964.     FW_CATCH_END
  1965. }
  1966.  
  1967. //---------------------------------------------------------------------------------------
  1968. //    FW_CODPart::WriteActionState
  1969. //---------------------------------------------------------------------------------------
  1970.  
  1971. void FW_CODPart::WriteActionState(Environment *ev,
  1972.                                     ODActionData* actionState,
  1973.                                     ODStorageUnitView* storageUnitView)
  1974. {
  1975. FW_UNUSED(actionState);
  1976. FW_UNUSED(storageUnitView);
  1977.     FW_TRY
  1978.     {
  1979.         FW_DEBUG_MESSAGE("WriteActionState: Not Yet Implemented");
  1980.     }
  1981.     FW_CATCH_BEGIN
  1982.     FW_CATCH_REFERENCE(FW_XException, exception)
  1983.     {
  1984.         FW_SetException(ev, exception);
  1985.     }
  1986.     FW_CATCH_EVERYTHING()
  1987.     {
  1988.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  1989.         FW_SetEvError(ev, kODErrUndefined);
  1990.     }
  1991.     FW_CATCH_END
  1992. }
  1993.  
  1994. //---------------------------------------------------------------------------------------
  1995. //    FW_CODPart::ReadActionState
  1996. //---------------------------------------------------------------------------------------
  1997.  
  1998. void FW_CODPart::ReadActionState(Environment *ev, ODStorageUnitView* storageUnitView, ODActionData* actionData)
  1999. {
  2000. FW_UNUSED(storageUnitView);
  2001. FW_UNUSED(actionData);
  2002.     FW_TRY
  2003.     {
  2004.          FW_DEBUG_MESSAGE("ReadActionState: Not Yet Implemented");
  2005.     }
  2006.     FW_CATCH_BEGIN
  2007.     FW_CATCH_REFERENCE(FW_XException, exception)
  2008.     {
  2009.         FW_SetException(ev, exception);
  2010.     }
  2011.     FW_CATCH_EVERYTHING()
  2012.     {
  2013.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2014.         FW_SetEvError(ev, kODErrUndefined);
  2015.     }
  2016.     FW_CATCH_END
  2017. }
  2018.  
  2019. //---------------------------------------------------------------------------------------
  2020. //    FW_CODPart::InitPart
  2021. //---------------------------------------------------------------------------------------
  2022.  
  2023. void FW_CODPart::InitPart(Environment *ev,
  2024.                         FW_CPart* part,
  2025.                         ODStorageUnit* storageUnit)
  2026. {        
  2027.     FW_TRY
  2028.     {
  2029.         // ----- Common initialization -----
  2030.         part->Initialize(ev);
  2031.     
  2032.         // ----- Add Needed Properties -----
  2033.         part->AddProperties(ev, storageUnit);
  2034.     }
  2035.     FW_CATCH_BEGIN
  2036.     FW_CATCH_REFERENCE(FW_XException, exception)
  2037.     {
  2038.         FW_SetException(ev, exception);
  2039.     }
  2040.     FW_CATCH_EVERYTHING()
  2041.     {
  2042.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2043.         FW_SetEvError(ev, kODErrUndefined);
  2044.     }
  2045.     FW_CATCH_END
  2046. }
  2047.  
  2048. //---------------------------------------------------------------------------------------
  2049. //    FW_CODPart::InitPartFromStorage
  2050. //---------------------------------------------------------------------------------------
  2051.  
  2052. void FW_CODPart::InitPartFromStorage(Environment *ev,
  2053.                                     FW_CPart* part,
  2054.                                     ODStorageUnit* storageUnit)
  2055. {
  2056.     FW_TRY
  2057.     {
  2058.         // ----- Common initialization -----
  2059.         part->Initialize(ev);
  2060.         
  2061.         // ----- Read Part Specific data -----
  2062.         part->InternalizeContent(ev, storageUnit, NULL);
  2063.     }
  2064.     FW_CATCH_BEGIN
  2065.     FW_CATCH_REFERENCE(FW_XException, exception)
  2066.     {
  2067.         FW_SetException(ev, exception);
  2068.     }
  2069.     FW_CATCH_EVERYTHING()
  2070.     {
  2071.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2072.         FW_SetEvError(ev, kODErrUndefined);
  2073.     }
  2074.     FW_CATCH_END
  2075. }
  2076.  
  2077. //---------------------------------------------------------------------------------------
  2078. //    FW_CODPart::Externalize
  2079. //---------------------------------------------------------------------------------------
  2080.  
  2081. void FW_CODPart::Externalize(Environment *ev, FW_CPart* part)
  2082. {
  2083.     FW_TRY
  2084.     {
  2085.         ODStorageUnit* partStorageUnit = part->GetStorageUnit(ev);
  2086.         
  2087.         if (partStorageUnit->GetDraft(ev)->GetPermissions(ev) >= kODDPSharedWrite)
  2088.         {    
  2089.             // ----- Create the necessary properties if necessary
  2090.             part->AddProperties(ev, partStorageUnit);
  2091.             
  2092.             // ----- Clean the content property -----
  2093.             part->PrivCleanseContentProperty(ev, partStorageUnit);
  2094.             
  2095.             // ----- Externalize part specific data -----
  2096.             part->ExternalizeContent(ev, partStorageUnit, NULL);
  2097.         }
  2098.     }
  2099.     FW_CATCH_BEGIN
  2100.     FW_CATCH_REFERENCE(FW_XException, exception)
  2101.     {
  2102.         FW_SetException(ev, exception);
  2103.     }
  2104.     FW_CATCH_EVERYTHING()
  2105.     {
  2106.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2107.         FW_SetEvError(ev, kODErrUndefined);
  2108.     }
  2109.     FW_CATCH_END
  2110. }
  2111.  
  2112. //---------------------------------------------------------------------------------------
  2113. //    FW_CODPart::Release
  2114. //---------------------------------------------------------------------------------------
  2115.  
  2116. void FW_CODPart::Release(Environment *ev, FW_CPart* part)
  2117. {
  2118.     FW_TRY
  2119.     {
  2120.         part->Release(ev);
  2121.     }
  2122.     FW_CATCH_BEGIN
  2123.     FW_CATCH_REFERENCE(FW_XException, exception)
  2124.     {
  2125.         FW_SetException(ev, exception);
  2126.     }
  2127.     FW_CATCH_EVERYTHING()
  2128.     {
  2129.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2130.         FW_SetEvError(ev, kODErrUndefined);
  2131.     }
  2132.     FW_CATCH_END
  2133. }
  2134.  
  2135. //---------------------------------------------------------------------------------------
  2136. //    FW_CODPart::ReleaseAll
  2137. //---------------------------------------------------------------------------------------
  2138.  
  2139. void FW_CODPart::ReleaseAll(Environment *ev, FW_CPart* part)
  2140. {
  2141.     FW_TRY
  2142.     {
  2143.         part->ReleaseAll(ev);
  2144.     }
  2145.     FW_CATCH_BEGIN
  2146.     FW_CATCH_REFERENCE(FW_XException, exception)
  2147.     {
  2148.         FW_SetException(ev, exception);
  2149.     }
  2150.     FW_CATCH_EVERYTHING()
  2151.     {
  2152.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2153.         FW_SetEvError(ev, kODErrUndefined);
  2154.     }
  2155.     FW_CATCH_END
  2156. }
  2157.  
  2158. //---------------------------------------------------------------------------------------
  2159. //    FW_CODPart::Purge
  2160. //---------------------------------------------------------------------------------------
  2161.  
  2162. ODSize FW_CODPart::Purge(Environment *ev, FW_CPart* part, ODSize size)
  2163. {
  2164.     ODSize bytesFreed = 0;
  2165.     
  2166.     FW_TRY
  2167.     {
  2168.         bytesFreed = part->Purge(ev, size);
  2169.     }
  2170.     FW_CATCH_BEGIN
  2171.     FW_CATCH_REFERENCE(FW_XException, exception)
  2172.     {
  2173.         FW_SetException(ev, exception);
  2174.     }
  2175.     FW_CATCH_EVERYTHING()
  2176.     {
  2177.         FW_DEBUG_MESSAGE(kUnknownExceptionString);
  2178.         FW_SetEvError(ev, kODErrUndefined);
  2179.     }
  2180.     FW_CATCH_END
  2181.     
  2182.     return bytesFreed;
  2183. }
  2184.